var t = require("../../../@babel/runtime/helpers/toConsumableArray"), a = getApp(), o = require("../../../mybehaviors/location/location");

Page({
    behaviors: [ o ],
    data: {
        currentPage: 1,
        totalPage: 0,
        commmunityStoreList: [],
        search: "",
        preSearch: "",
        noDatas: !1,
        point: {},
        address: "",
        city: ""
    },
    onLoad: function(t) {
        var a = this;
        this._getLocation(function(t, o) {
            a._getData();
        });
    },
    chooseCommunityStore: function(t) {
        wx.navigateTo({
            url: "/packageH/o2o/communityStoreDetails/communityStoreDetails?id=" + t.currentTarget.dataset.id
        });
    },
    showcarrfoot: function(t) {
        this.setData({
            showcarrfootBol: !0
        });
    },
    showcarrfoot_ipx: function(t) {
        this.setData({
            showcarrfoot_ipxBol: !0
        });
    },
    initData: function() {
        this.setData({
            commmunityStoreList: [],
            totalPage: 0,
            currentPage: 1
        });
    },
    _getData: function() {
        this.initData();
        var t = this, o = a.getNetAddresss("plugin.store-community.frontend.community.getList");
        console.log(o, "urlStr"), t.data.city ? a._getNetWork({
            url: o,
            data: {
                lng: t.data.point.lng,
                lat: t.data.point.lat,
                city_name: t.data.city,
                page: t.data.currentPage,
                kwd: t.data.search
            },
            success: function(a) {
                var o = a.data;
                if (1 === o.result && o.data.list.data.length > 0) {
                    var e = o.data.list.data;
                    t.setData({
                        commmunityStoreList: e,
                        totalPage: o.data.list.last_page,
                        currentPage: o.data.list.current_page,
                        noDatas: !1
                    }), wx.setNavigationBarTitle({
                        title: o.data.plugin_name
                    });
                } else t.setData({
                    noDatas: !0
                });
            },
            fail: function(t) {
                console.log(t);
            }
        }) : t.setData({
            noDatas: !0
        });
    },
    tolocation: function() {
        wx.navigateTo({
            url: "/packageC/o2o/o2oLocation/o2oLocation?tag=communityStore"
        });
    },
    getCommunityStoreListBySearch: function() {
        var t = this.data.search.trim();
        t.trim() != this.data.preSearch && (this.setData({
            preSearch: t.trim()
        }), this._getData());
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    _getMoreData: function() {
        var o = this, e = a.getNetAddresss("plugin.store-community.frontend.community.getList");
        console.log(e, "urlStr"), a._getNetWork({
            url: e,
            data: {
                lng: o.data.point.lng,
                lat: o.data.point.lat,
                city_name: o.data.city,
                page: o.data.currentPage,
                kwd: o.data.search
            },
            success: function(a) {
                var e = a.data;
                if (1 === e.result && e.data.list.data.length > 0) {
                    var i = [].concat(t(o.data.commmunityStoreList), t(e.data.list.data));
                    o.setData({
                        commmunityStoreList: i
                    });
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReachBottom: function() {
        0 != this.data.totalPage && this.data.totalPage > this.data.currentPage ? (console.info("还有数据可以请求"), 
        this.setData({
            currentPage: this.data.currentPage + 1
        }), this._getMoreData()) : console.info("没有数据可以请求");
    },
    onShareAppMessage: function() {}
});